<template>
  <div class="components-container goods">

  <el-form :inline="true" :model="formInline" class="demo-form-inline fnsbg">
      <el-col :span="20">
      <!-- <el-form-item label="分配岗位">
      <el-select v-model="formInline.roleId" placeholder="请选择岗位" clearable>
        <el-option
          v-for="(item, index) in rolesOptions"
          :key="index"
          :label="item.keyName"
          :value="item.valueName">
        </el-option>
      </el-select>
      </el-form-item> -->
        <el-form-item label="批次">
          <el-input v-model="formInline.goodsPassel" :clearable="true"  placeholder="请输入批次"></el-input>
        </el-form-item>
        <el-form-item label="汽车品牌">
          <el-input v-model="formInline.brandName" :clearable="true"  placeholder="请输入汽车品牌"></el-input>
        </el-form-item>
        <el-form-item label="VIN码">
          <el-input v-model="formInline.vinCode" :clearable="true" placeholder="请输入VIN码"></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <template>
            <el-select v-model="formInline.status" clearable placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="queryList" size="medium" icon="el-icon-search">查询</el-button>
        </el-form-item>
        </el-col>
        <el-col :span="4" style="text-align:right;">
        <el-form-item style="margin-right:20px!important;">
          <el-button type="primary" size="medium" icon="el-icon-plus" @click="added('add')" v-show="showAdd">新增</el-button>
        </el-form-item>
        <el-form-item style="margin-right:0!important;">
          <el-button type="primary" size="medium" icon="el-icon-upload2" @click="goodsExport" v-show="showExport">导出</el-button>
        </el-form-item>
      </el-col>
  </el-form>

      <template>
        <el-table v-loading="loading" :data="tableData" border style="width: 100%" class="fns-table">
          <el-table-column prop="goodsPassel" align="center" label="批次" min-width="140"></el-table-column>
          <!-- <el-table-column prop="goodsCode"align="center" label="编号" min-width="150"></el-table-column> -->
          <el-table-column prop="brandName" align="center" label="汽车品牌" min-width="120"></el-table-column>
          <el-table-column prop="modelName" align="center" label="型号规格" min-width="220"></el-table-column>
          <el-table-column prop="extcolor" align="center" label="外观颜色" min-width="80"></el-table-column>
          <el-table-column prop="nercolor" align="center" label="内饰颜色" min-width="80"></el-table-column>
          <el-table-column prop="vinCode" align="center" label="VIN码" min-width="150"></el-table-column>
          <el-table-column prop="check" align="center" label="附件是否齐全" min-width="90"></el-table-column>
          <!-- <el-table-column prop="certificateApproval" align="center" label="合格证号" min-width="140"></el-table-column> -->
          <el-table-column align="center" label="状态" max-width="80">
            <template slot-scope="scope">
              <span>{{scope.row.status == '0'?'待完善': scope.row.status == '1'?'已完善': scope.row.status == '2'?'可销售': scope.row.status == '3'?'已锁定':'已销售'}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="updatedOn" align="center" label="修改时间" min-width="160"></el-table-column>
          <el-table-column prop="updatedBy" align="center" label="最新修改人" min-width="100"></el-table-column>
          <el-table-column label="操作" min-width="80" align="center">
            <template slot-scope="scope">
              <el-tooltip content="修改" placement="top" v-show="showUpdate">
                <a  v-if="(scope.row.status == '0' || scope.row.status == '1')" @click="added('update', scope.$index, scope.row)" style="margin-right:10px;">
                  <i class="el-icon-edit-outline"></i>
                </a>
              </el-tooltip>
              <el-tooltip content="删除" placement="top" v-show="showDelete">
                <a v-if="(scope.row.status == '0' || scope.row.status == '1' || scope.row.status == '2')" @click="handleDelete(scope.$index, scope.row.id)">
                  <i class="el-icon-delete"></i>
                </a>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </template>

      <!-- ========分页======-->
    <pages v-on:_pageChange="_pageChange" :total="total"></pages>

      <el-dialog
        :title="modelTitle"
        :visible.sync="dialogVisible"
        class="fns-el-dialog-md"
        width="960px"
        :before-close="handleClose"
        :close-on-click-modal="false">
        <el-form label-width="110px" :model="formAdd" ref="formAdd" :rules="rules" style="height:535px; overflow-y:auto; padding-right:20px;">
          <span class="cartitle">基本信息</span>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="批次：" prop="goodsPassel">
                <el-input v-model="formAdd.goodsPassel" clearable placeholder="请输入批次"></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
              <el-form-item label="编号：">
                <el-input v-model="formAdd.goodsCode" disabled placeholder=""></el-input>
              </el-form-item>
            </el-col> -->
            <el-col :span="8">
              <el-form-item label="汽车品牌：" prop="brandId">
                <el-select v-model="formAdd.brandId" @change="brandChange()" filterable placeholder="可搜索选择" clearable>
                  <el-option
                    v-for="(item, index) in brandOptions"
                    :key="index"
                    :label="item.keyName"
                    :value="item.valueName">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="型号规格：" prop="modelId">
                <el-select v-model="formAdd.modelId" filterable placeholder="可搜索选择" clearable>
                  <el-option
                    v-for="(item, index) in modelList"
                    :key="index"
                    :label="item.keyName"
                    :value="item.valueName">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="外观颜色：" prop="extcolor">
                <el-select v-model="formAdd.extcolor" placeholder="可搜索选择" filterable clearable>
                  <el-option
                    v-for="(item, index) in colourOptions"
                    :key="index"
                    :label="item.keyName"
                    :value="item.keyName">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="内饰颜色：" prop="nercolor">
                <el-select v-model="formAdd.nercolor" placeholder="可搜索选择" filterable clearable>
                  <el-option
                    v-for="(item, index) in colourOptions"
                    :key="index"
                    :label="item.keyName"
                    :value="item.keyName">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <span class="cartitle">车辆详情</span>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="VIN码：" prop="vinCode">
                <el-input type="text" v-model="formAdd.vinCode" :maxlength="17" placeholder="请输入VIN码" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
          <el-col :span="8">
              <el-form-item label="钥匙：">
                <el-radio-group v-model="formAdd.keyCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="用户手册：">
                <el-radio-group v-model="formAdd.userCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="环保随车清单：">
                <el-radio-group v-model="formAdd.envCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="安全检测单：">
                <el-radio-group v-model="formAdd.safeCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="三包手册：">
                <el-radio-group v-model="formAdd.threeCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="保养手册：">
                <el-radio-group v-model="formAdd.healthCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="一致性证书：">
                <el-radio-group v-model="formAdd.conformityCheck">
                  <el-radio :label="true">齐 全</el-radio>
                  <el-radio :label="false">不 齐</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <el-form-item label="备注：">
                <el-input v-model="formAdd.remark" type="textarea" :rows="2" :maxlength="300" placeholder="请填写备注(选填)" clearable></el-input>
                <!-- <span class="word-counter" v-show="contentShortLength">{{contentShortLength}} 字</span> -->
              </el-form-item>
            </el-col>
          </el-row>
          <span class="cartitle">接车信息</span>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="接车日期：">
                <el-date-picker
                  v-model="formAdd.receiptDate"
                  @change="getReceipt"
                  value-format="yyyy-MM-dd"
                  type="date"
                  placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="接车城市：">
                <el-input v-model="formAdd.receiptCity" placeholder="请输入" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="接车人：">
                <el-input v-model="formAdd.consignee" :maxlength="10" placeholder="请输入" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <span class="cartitle">合格证</span>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="合格证号：">
                <el-input v-model="formAdd.certificateApproval" :maxlength="20" placeholder="请输入合格证号" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="生产日期：">
                <el-date-picker
                  v-model="formAdd.productionDate"
                  @change="getProduction"
                  value-format="yyyy-MM-dd"
                  type="date"
                  placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="发动机号：">
                <el-input v-model="formAdd.engineNumber" :maxlength="20" placeholder="请输入发动机号" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitAdd('formAdd')">提 交</el-button>
        </span>
      </el-dialog>
  </div>
</template>

<script>
import { Message } from 'element-ui'
import * as api from '@/api/system'
import pages from '../../components/page/page'
import { findMenu, findSubMenu, findBtn } from '@/utils/btn'
import { mapState } from 'vuex'
import { mapActions } from 'vuex'
export default {
  data() {
    return {
      loading: false,
      total: 0,
      dialogVisible: false,
      modelTitle: '',
      addOrUpdate: 'add',
      page: {
        index: 1,
        size: 10
      },
      formInline: {
        goodsPassel: '',
        brandName: '',
        vinCode: '',
        status: ''
      },
      options: [{
        value: '0',
        label: '待完善'
      }, {
        value: '1',
        label: '已完善'
      }, {
        value: '2',
        label: '可销售'
      }, {
        value: '3',
        label: '已锁定'
      }, {
        value: '4',
        label: '已销售'
      }],
      brandList: [],
      modelList: [],
      tableData: [],
      formAdd: {
        id: '',
        goodsPassel: '',
        goodsCode: '',
        brandId: '',
        modelId: '',
        extcolor: '',
        nercolor: '',
        vinCode: '',
        keyCheck: true,
        userCheck: true,
        envCheck: true,
        safeCheck: true,
        threeCheck: true,
        healthCheck: true,
        conformityCheck: true,
        remark: '',
        receiptDate: '',
        receiptCity: '',
        consignee: '',
        certificateApproval: '',
        productionDate: '',
        engineNumber: ''
      },
      colourOptions: [],
      rules: {
        goodsPassel: [
          { required: true, message: '批次不能为空', trigger: 'blur' }
        ],
        // goodsCode: [
        //   { required: true, message: '编号不能为空', trigger: 'blur' }
        // ],
        brandId: [
          { required: true, message: '品牌不能为空', trigger: 'change' }
        ],
        modelId: [
          { required: true, message: '型号规格不能为空', trigger: 'change' }
        ],
        extcolor: [
          { required: true, message: '外观颜色不能为空', trigger: 'change' }
        ],
        nercolor: [
          { required: true, message: '内饰颜色不能为空', trigger: 'change' }
        ],
        vinCode: [
          { required: false, message: '', trigger: 'blur' },
          { min: 17, max: 17, message: '请输入正确的17位VIN码', trigger: 'blur' },
          { pattern: /^(?!.*(Q|q|I|i|O|o)).*$/, message: 'VIN码不能包含I,O,Q三个字母', trigger: 'blur' }
        ],
        receiptDate: [
          { required: true, message: '请选择接车日期', trigger: 'blur' }
        ],
        receiptCity: [
          { required: true, message: '请选择接车城市', trigger: 'blur' }
        ],
        consignee: [
          { required: true, message: '接车人不能为空', trigger: 'blur' }
        ],
        certificateApproval: [
          { required: true, message: '请输入合格证号', trigger: 'blur' }
        ],
        productionDate: [
          { required: true, message: '请选择生产日期', trigger: 'blur' }
        ],
        engineNumber: [
          { required: true, message: '请输入发动机号', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    dialogVisible() {
      if (this.$refs.formAdd) {
        this.$refs.formAdd.clearValidate()
      }
    }
  },
  components: {
    pages
  },
  created() {
    // 初始化所有岗位
    if (this.$route.params.uuid) {
      this.formInline.id = this.$route.params.uuid
      this.queryList()
    } else {
      this.queryList()
    }
    api.colourRole().then((res) => {
      this.colourOptions = res.data
    })
  },
  computed: {
    ...mapState({
      brandOptions: state => state.selecteData.brandOptions,
      policyBrandOptions: state => state.selecteData.policyBrandOptions
    }),
    contentShortLength() {
      return this.formAdd.remark.length
    },
    showAdd() {
      let menu = findMenu('销售管理')
      let subMenu = findSubMenu(menu.children, '商品管理')
      if (findBtn(subMenu.children, '新增')) {
        return true
      } else {
        return false
      }
    },
    showDelete() {
      let menu = findMenu('销售管理')
      let subMenu = findSubMenu(menu.children, '商品管理')
      if (findBtn(subMenu.children, '删除')) {
        return true
      } else {
        return false
      }
    },
    showUpdate() {
      let menu = findMenu('销售管理')
      let subMenu = findSubMenu(menu.children, '商品管理')
      if (findBtn(subMenu.children, '修改')) {
        return true
      } else {
        return false
      }
    },
    showExport() {
      let menu = findMenu('销售管理')
      let subMenu = findSubMenu(menu.children, '商品管理')
      if (findBtn(subMenu.children, '导出')) {
        return true
      } else {
        return false
      }
    }
  },
  methods: {
    getReceipt (val) {
      this.formAdd.receiptDate = val;
    },
    getProduction (val) {
      this.formAdd.productionDate = val;
    },
    // 分页和列表
    _pageChange(val, flag) {
      var arr = []
      if (flag === 'size') {
        this.page.index = val
        this.queryList()
      } else {
        arr.push(val)
        this.page.index = 1
        this.page.size = arr[0]
        this.queryList()
      }
    },
    // 获取列表数据
    queryList(val) {
      this.loading = true
      var pages = {
        index: this.page.index,
        size: this.page.size || val
      }
      var data = Object.assign(this.formInline, pages)
      api.goodList(data).then((res) => {
        if (+res.code === 0) {
          this.tableData = res.data.rows
          this.total = +res.data.total
          this.formInline.id = ''
        }
        this.loading = false
      }).catch(err => {
        console.log(err)
        this.loading = false
      })
    },
    //获取品牌
    // brandChange() {
    //   this.formAdd.modelId = ''
    //   if(this.formAdd.brandId === ''){

    //   }
    //   api.ownBrand(this.formAdd.brandId).then((res) => {
    //     this.modelList = res.data.rows
    //   })
    // },
    brandChange() {
      this.formAdd.modelId = ''
      if (this.formAdd.brandId === '') {
        this.modelList = []
        return
      } else {
          api.ownBrand({'id': this.formAdd.brandId}).then((res) => {
          this.modelList = res.data
          console.log(res.data)
        })
      }
    },
    // modelChange() {
    //   api.getStockByModelId(this.formAdd.modelId).then((res) => {
    //   })
    // },
    // 点击弹出新增窗口
    added(val, index, row) {
      if (val === 'add') {
        // this.brandOptions
        this.formAdd.goodsPassel = ''
        this.formAdd.goodsCode = ''
        this.formAdd.brandId = ''
        this.formAdd.modelId = ''
        this.modelList = []
        this.formAdd.extcolor = ''
        this.formAdd.nercolor = ''
        this.formAdd.vinCode = ''
        this.formAdd.keyCheck = true
        this.formAdd.userCheck = true
        this.formAdd.envCheck = true
        this.formAdd.safeCheck = true
        this.formAdd.threeCheck = true
        this.formAdd.healthCheck = true
        this.formAdd.conformityCheck = true
        this.formAdd.remark = ''
        this.formAdd.receiptDate = ''
        this.formAdd.receiptCity = '佛山'
        this.formAdd.consignee = ''
        this.formAdd.certificateApproval = ''
        this.formAdd.engineNumber = ''

        this.modelTitle = '新增商品'
        this.dialogVisible = true
        this.addOrUpdate = 'add'
      } else {
        this.brandOptions
        this.modelTitle = '修改商品'
        this.dialogVisible = true
        this.addOrUpdate = 'update'
        this.edit(row)
      }
      this.modalTitle = '新增'
      this.dialogVisible = true
    },

    // 根据ID获取用户信息
    edit(row) {
      this.modalTitle = '修改'
      this.dialogVisible = true
      const id = { id: row.id }
      api.goodUpdate(id).then((res) => {
        if (+res.code === 0) {
          var rowData = res.data
          this.formAdd.id = rowData.id || ''
          this.formAdd.goodsPassel = rowData.goodsPassel || ''
          this.formAdd.goodsCode = rowData.goodsCode || ''
          this.formAdd.brandId = String(rowData.brandId) || ''
          this.formAdd.modelId = String(rowData.modelId) || ''
          // api.ownBrand(this.formAdd.brandId).then((res) => {
          //   this.modelList = res.data.rows
          // })
          api.modelPageListNoAuth(this.formAdd.brandId).then((res) => {
            this.modelList = res.data
           /* let modelListTmp= res.data.rows
            let modelListTmp2 = []
            modelListTmp.forEach(item => {
              let { id, modelName } = item
              const item2 = { id, modelName }
              let { id:valueName, modelName:keyName } = item2
              const item3 = { valueName, keyName }
              modelListTmp2.push(item3)
            })
            this.modelList = modelListTmp2*/
          })
          this.formAdd.extcolor = rowData.extcolor || ''
          this.formAdd.nercolor = rowData.nercolor || ''
          this.formAdd.vinCode = rowData.vinCode || ''
          this.formAdd.keyCheck = rowData.keyCheck
          this.formAdd.userCheck = rowData.userCheck
          this.formAdd.envCheck = rowData.envCheck
          this.formAdd.safeCheck = rowData.safeCheck
          this.formAdd.threeCheck = rowData.threeCheck
          this.formAdd.healthCheck = rowData.healthCheck
          this.formAdd.conformityCheck = rowData.conformityCheck
          this.formAdd.remark = rowData.remark || ''
          this.formAdd.receiptDate = rowData.receiptDate || ''
          this.formAdd.receiptCity = rowData.receiptCity || ''
          this.formAdd.consignee = rowData.consignee || ''
          this.formAdd.certificateApproval = rowData.certificateApproval || ''
          this.formAdd.productionDate = rowData.productionDate || ''
          this.formAdd.engineNumber = rowData.engineNumber || ''
        }
      })
    },
    // 修改
    // handleEdit() {
    //   this.$refs['formAdd'].validate((valid) => {
    //     if (valid) {
    //       api.goodEdit(this.formAdd).then(res => {
    //         if (+res.code === 0) {
    //           this.formEdit = {}
    //           this.queryList()
    //           this.dialogVisible = false
    //         }
    //       }).catch(err => {
    //         console.log(err)
    //       })
    //     } else {
    //       return
    //     }
    //   })
    // },
    submitAdd(formAdd) {
      this.$refs[formAdd].validate((valid) => {
        if (valid) {
          if (this.addOrUpdate === 'add') {
            this.addformAdd()
          } else {
            this.editformAdd()
          }
        } else {
          return false
        }
      })
    },
    addformAdd() {
      // var Cts = this.formAdd.vinCode;
      //   if(Cts.indexOf("i") > 0 || Cts.indexOf("o") > 0 || Cts.indexOf("q") > 0 || Cts.indexOf("I") > 0 || Cts.indexOf("O") > 0 || Cts.indexOf("Q") > 0){
      //    this.$message({
      //       message: 'VIN码不能包含I,O,Q三个字母',
      //       type: 'warning',
      //       showClose: true
      //     })
      //   } 
      delete this.formAdd.id
      this.formAdd.brandId = parseInt(this.formAdd.brandId)
      api.goodAdd(this.formAdd).then((res) => {
        if (+res.code === 0) {
          this.dialogVisible = false
          this.queryList()
          this.$message({
            message: '新增成功',
            type: 'success',
            showClose: true
          })
        }
      }).catch(err => {
        if(+err.code === 1020){
          this.$message({
            message: '商品已经存在,VIN码不能重复',
            type: 'error',
            showClose: true
          })
        }
      })
    },
    editformAdd() {
      this.formAdd.brandId = parseInt(this.formAdd.brandId)
      api.goodEdit(this.formAdd).then((res) => {
        if (+res.code === 0) {
          this.dialogVisible = false
          this.queryList()
          this.$message({
            message: '修改成功',
            type: 'success',
            showClose: true
          })
          // this.$set(this.formAdd, 'goodsPassel', '');
          // this.$set(this.formAdd, 'goodsCode', '');
          // this.$set(this.formAdd, 'brandId', '');
          // this.$set(this.formAdd, 'modelId', '');
          // this.$set(this.formAdd, 'extcolor', '');
          // this.$set(this.formAdd, 'nercolor', '');
          // this.$set(this.formAdd, 'vinCode', '');
          // this.$set(this.formAdd, 'keyCheck', '');
          // this.$set(this.formAdd, 'userCheck', '');
          // this.$set(this.formAdd, 'envCheck', '');
          // this.$set(this.formAdd, 'safeCheck', '');
          // this.$set(this.formAdd, 'threeCheck', '');
          // this.$set(this.formAdd, 'healthCheck', '');
          // this.$set(this.formAdd, 'conformityCheck', '');
          // this.$set(this.formAdd, 'remark', '');
          // this.$set(this.formAdd, 'receiptDate', '');
          // this.$set(this.formAdd, 'receiptCity', '佛山');
          // this.$set(this.formAdd, 'consignee', '');
          // this.$set(this.formAdd, 'certificateApproval', '');
          // this.$set(this.formAdd, 'engineNumber', '');
         }
      }).catch(err => {
        this.$message({
          message: '修改失败',
          type: 'error',
          showClose: true
        })
      })
    },
    // 删除商品
    handleDelete(index ,id) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
      .then(() => {
        api.goodDelete(id).then((res) => {
          if (+res.code === 0) {
            this.$message({
            type: 'success',
            message: '删除成功!'
          })
          this.queryList()
          }
        })
      })
    },
    // 商品导出
    goodsExport () {
      var aLink = document.createElement('a')
      aLink.href = api.goodExport + '?goodsPassel=' + this.formInline.goodsPassel + '&brandName=' + this.formInline.brandName + '&vinCode=' + this.formInline.vinCode + '&status=' + this.formInline.status
      /*api.goodExport(this.formInline).then((res) => {
        aLink.href = res
      })*/
      aLink.click()
    },
    // 关闭弹窗
    handleClose(done) {
      this.dialogVisible = false
    }
  }
}
</script>
<style lang="scss">
.goods {
  .redco {
    font-size:14px;
    color:#f56c6c;
    padding-left:120px!important;
  }
 .fnsbg .el-form-item{margin-bottom:22px!important;}
 .el-form-item{margin-bottom:22px!important;}
  .cartitle{font-size:16px;margin-bottom:10px;display:inline-block;padding-left:10px;padding-bottom:5px;}
  .word-counter {
      width: 100%;
      position: relative;
      right: 0;
      top: 0;
      display:inline-block;
      text-align:right;
    }
    .el-date-editor.el-input, .el-date-editor.el-input__inner{width:inherit;}
    // .el-table{
    //   position: relative;
    //   height: 651px;
    //   overflow-y: scroll;
    // }
    // .el-table::before{height:0;}

}

</style>
